<?php

namespace core\system;

class HttpResponse {
    /*
     * method chuyển trang
     * Input: URL,  thời gian, Kiểu nhảy trang, mặc định HTMl /Javascript
     */

    public static function redirect($url = "", $time = 0, $target = "_self", $type = 'html') {
        if ($type == 'html') {
            echo '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '">';
        } else {
            $time = $time * 1000;
            if ($target == "_self") {
                echo '<script language="javascript">setTimeout("window.location.href=\'' . $url . '\'", ' . $time . '); </script>';
            } else {
                echo '<script language="javascript">setTimeout("window.open(\'' . $url . '\')"); </script>';
            }
        }
    }

}
